gdk_x11_display_make_gl_context_current: move some code
authorAlexander Larsson <alexl@redhat.com>
Thu, 30 Oct 2014 15:04:28 +0000 (16:04 +0100)
committerAlexander Larsson <alexl@redhat.com>
Thu, 30 Oct 2014 20:04:29 +0000 (21:04 +0100)
This moves the code related to the frame sync code into
the is_attached check, which means we don't have to ever
run this when making non-window-paint contexts current.

This is a minior speed thing, but the main advantage
is that it makes making a non-paint context current
threadsafe.

gdk/x11/gdkglcontext-x11.c

index 9c2d9a9751276c15cc08dcb565d9b8ba23c66148..4315bfd7aa954ead8ba4277c24f19962ec493f3e 100644 (file)
@@ -1152,17 +1152,6 @@ gdk_x11_display_make_gl_context_current (GdkDisplay   *display,
 
   context_x11 = GDK_X11_GL_CONTEXT (context);
 
-  window = gdk_gl_context_get_window (context);
-
-  // If the WM is compositing there is no particular need to delay
-  // the swap when drawing on the offscreen, rendering to the screen
-  // happens later anyway, and its up to the compositor to sync that
-  // to the vblank.
-  screen = gdk_window_get_screen (window);
-  do_frame_sync = ! gdk_screen_is_composited (screen);
-
-  context_x11->do_frame_sync = do_frame_sync;
-
   GDK_NOTE (OPENGL,
             g_print ("Making GLX context current to drawable %lu\n",
                      (unsigned long) context_x11->drawable));
@@ -1177,6 +1166,17 @@ gdk_x11_display_make_gl_context_current (GdkDisplay   *display,
 
   if (context_x11->is_attached && GDK_X11_DISPLAY (display)->has_glx_swap_interval)
     {
+      window = gdk_gl_context_get_window (context);
+
+      /* If the WM is compositing there is no particular need to delay
+       * the swap when drawing on the offscreen, rendering to the screen
+       * happens later anyway, and its up to the compositor to sync that
+       * to the vblank. */
+      screen = gdk_window_get_screen (window);
+      do_frame_sync = ! gdk_screen_is_composited (screen);
+
+      context_x11->do_frame_sync = do_frame_sync;
+
       if (context_x11->do_frame_sync)
         glXSwapIntervalSGI (1);
       else